package com.fin.zw.intelligentbot.model.base;

import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;


public class Task {
    private String id;

    private String name;//任务名称

    private Integer count;//客户数量

    private String status;//任务状态

    private Date startTime;//开始时间

    private Date endTime;//结束时间

    private Date createTime;//创建时间

    private Integer connectCount;//电话接通数量

    private Integer calledCount;//呼叫数量

    private String parentId;//上级id

    private String initId;//初始创建任务id

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getConnectCount() {
        return connectCount;
    }

    public void setConnectCount(Integer connectCount) {
        this.connectCount = connectCount;
    }

    public Integer getCalledCount() {
        return calledCount;
    }

    public void setCalledCount(Integer calledCount) {
        this.calledCount = calledCount;
    }

    public List<Customer> getCustomers() {
        return customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
        this.count = customers.size();
        if (Objects.isNull(this.connectCount))
            this.connectCount = customers.stream()
                    .filter((Customer c) -> c.getStatus().equalsIgnoreCase("connected"))
                    .collect(Collectors.toList())
                    .size();
        if (Objects.isNull(this.calledCount))
            this.calledCount = this.count - customers.stream()
                    .filter((Customer c) -> c.getStatus().equalsIgnoreCase("ready") || c.getStatus().equalsIgnoreCase("new"))
                    .collect(Collectors.toList())
                    .size();
    }

    private List<Customer> customers;

    private Set<Robot> robotSet;//机器人

    public Set<Robot> getRobotSet() {
        return robotSet;
    }

    public void setRobotSet(Set<Robot> robotSet) {
        this.robotSet = robotSet;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getInitId() {
        return initId;
    }

    public void setInitId(String initId) {
        this.initId = initId;
    }
}
